<?php

/**
 * Site filter form base class.
 *
 * @package    Web20
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseSiteFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'                => new sfWidgetFormFilterInput(),
      'description'         => new sfWidgetFormFilterInput(),
      'logo'                => new sfWidgetFormFilterInput(),
      'payment_enabled'     => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'dineromail_store_id' => new sfWidgetFormFilterInput(),
      'background_image'    => new sfWidgetFormFilterInput(),
      'color_1'             => new sfWidgetFormFilterInput(),
      'color_2'             => new sfWidgetFormFilterInput(),
      'color_3'             => new sfWidgetFormFilterInput(),
      'location'            => new sfWidgetFormFilterInput(),
      'font'                => new sfWidgetFormFilterInput(),
      'user_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
      'category_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => true)),
      'slug'                => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'name'                => new sfValidatorPass(array('required' => false)),
      'description'         => new sfValidatorPass(array('required' => false)),
      'logo'                => new sfValidatorPass(array('required' => false)),
      'payment_enabled'     => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'dineromail_store_id' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'background_image'    => new sfValidatorPass(array('required' => false)),
      'color_1'             => new sfValidatorPass(array('required' => false)),
      'color_2'             => new sfValidatorPass(array('required' => false)),
      'color_3'             => new sfValidatorPass(array('required' => false)),
      'location'            => new sfValidatorPass(array('required' => false)),
      'font'                => new sfValidatorPass(array('required' => false)),
      'user_id'             => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('User'), 'column' => 'id')),
      'category_id'         => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Category'), 'column' => 'id')),
      'slug'                => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('site_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Site';
  }

  public function getFields()
  {
    return array(
      'id'                  => 'Number',
      'name'                => 'Text',
      'description'         => 'Text',
      'logo'                => 'Text',
      'payment_enabled'     => 'Boolean',
      'dineromail_store_id' => 'Number',
      'background_image'    => 'Text',
      'color_1'             => 'Text',
      'color_2'             => 'Text',
      'color_3'             => 'Text',
      'location'            => 'Text',
      'font'                => 'Text',
      'user_id'             => 'ForeignKey',
      'category_id'         => 'ForeignKey',
      'slug'                => 'Text',
    );
  }
}
